import os
import logging
import glob
import uuid
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
logger = logging.getLogger(__name__)


def get_master_host():

    if not os.path.isfile("/root/.master_host"):

        return ''

    with open("/root/.master_host") as f:

        return f.read()
    
def get_mac_address():
    "获取系统的MacAddress"

    if glob.glob("/root/.mac"):
        
        with open('/root/.mac') as f:

            mac = f.read().strip()
    else:    
        node = uuid.getnode()

        mac = uuid.UUID(int=node).hex[-12:]

    return mac

MAC = get_mac_address()

NS_HOST = "localhost:8080"

MQTT_LOCAL_HOST = get_master_host()

MQTT_LOCAL_PORT = 1883

MQTT_LOCAL_PUBLISH_TOPIC = "base_station_publish_channel"

MQTT_LOCAL_SUBSCRIPTION_TOPIC = f"{MAC}_transcations"